<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8" />
    <title>审批事项</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta
            name="viewport"
            content="width=device-width, initial-scale=1, maximum-scale=1"
    />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <!--    <link rel="stylesheet" href="../css/amis/sdk.css" />-->
    <link rel="stylesheet" href="https://houtai.baidu.com/v2/csssdk"/>
    <style>
        html,
        body,
        .app-wrapper {
            position: relative;
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
        }
    </style>
</head>
<body>
<div id="root" class="app-wrapper"></div>
<!--<script src="../js/amis/sdk.js"></script>-->
<!--<script src="../js/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>-->
<script src="https://houtai.baidu.com/v2/jssdk"></script>
<script type="text/javascript">

    //这里是我的判断是否登录的逻辑，与amis无关
    // //初始化页面判断用户是否登录
    // $.ajax({
    //     url:"/restapi/bpm/initUserData",  // ajax请求要请求的地址
    //     async:false,
    //     type:"get", // 请求的类型  get  post
    //     // data:"", // 请求要发送的数据  常在post请求中使用，get请求只需要拼接请求的url就可以
    //     success:function (result) {
    //         // 请求成功之后要执行的方法
    //         // data  接收请求成功之后的返回值
    //         console.log(result);
    //         if(result.status!=0){
    //             // var url = data.data.url;
    //             // window.location.href = data.data.url;
    //             document.write(result);
    //         }
    //     },
    // });


    (function () {
        let amis = amisRequire('amis/embed');
        let amisScoped = amis.embed('#root', {
  "title": "增删改查示例",
  "remark": "bla bla bla",
  "toolbar": [
    {
      "type": "button",
      "actionType": "dialog",
      "label": "新增",
      "icon": "fa fa-plus pull-left",
      "primary": true,
      "dialog": {
        "title": "新增",
        "body": {
          "type": "form",
          "name": "sample-edit-form",
          "api": "post:/amis/api/sample",
          "body": [
            {
              "type": "input-text",
              "name": "engine",
              "label": "Engine",
              "required": true
            },
            {
              "type": "divider"
            },
            {
              "type": "input-text",
              "name": "browser",
              "label": "Browser",
              "required": true
            },
            {
              "type": "divider"
            },
            {
              "type": "input-text",
              "name": "platform",
              "label": "Platform(s)",
              "required": true
            },
            {
              "type": "divider"
            },
            {
              "type": "input-text",
              "name": "version",
              "label": "Engine version"
            },
            {
              "type": "divider"
            },
            {
              "type": "input-text",
              "name": "grade",
              "label": "CSS grade"
            }
          ]
        }
      }
    }
  ],
  "body": {
    "type": "crud",
    "draggable": true,
    "api": "/amis/api/sample?waitSeconds=1",
    "perPage": 15,
    "keepItemSelectionOnPageChange": true,
    "maxKeepItemSelectionLength": 11,
    "labelTpl": "${id} ${engine}",
    "orderBy": "id",
    "orderDir": "asc",
    "filter": {
      "title": "条件搜索",
      "submitText": "",
      "body": [
        {
          "type": "input-text",
          "name": "keywords",
          "placeholder": "通过关键字搜索",
          "addOn": {
            "label": "搜索",
            "type": "submit"
          }
        },
        {
          "type": "plain",
          "text": "这里的表单项可以配置多个"
        }
      ]
    },
    "bulkActions": [
      {
        "label": "批量删除",
        "actionType": "ajax",
        "api": "delete:/amis/api/sample/${ids|raw}",
        "confirmText": "确定要批量删除?"
      },
      {
        "label": "批量修改",
        "actionType": "dialog",
        "dialog": {
          "title": "批量编辑",
          "name": "sample-bulk-edit",
          "body": {
            "type": "form",
            "api": "/amis/api/sample/bulkUpdate2",
            "body": [
              {
                "type": "hidden",
                "name": "ids"
              },
              {
                "type": "input-text",
                "name": "engine",
                "label": "Engine"
              }
            ]
          }
        }
      }
    ],
    "quickSaveApi": "/amis/api/sample/bulkUpdate",
    "quickSaveItemApi": "/amis/api/sample/$id",
    "filterTogglable": true,
    "headerToolbar": [
      "filter-toggler",
      "bulkActions",
      {
        "type": "tpl",
        "tpl": "定制内容示例：当前有 ${count} 条数据。",
        "className": "v-middle"
      },
      {
        "type": "link",
        "href": "https://www.baidu.com",
        "body": "百度一下",
        "htmlTarget": "_parent",
        "className": "v-middle"
      },
      {
        "type": "columns-toggler",
        "align": "right"
      },
      {
        "type": "drag-toggler",
        "align": "right"
      },
      {
        "type": "pagination",
        "align": "right"
      }
    ],
    "footerToolbar": [
      "statistics",
      "switch-per-page",
      "pagination"
    ],
    "columns": [
      {
        "name": "id",
        "label": "ID",
        "width": 20,
        "sortable": true,
        "type": "text",
        "toggled": true,
        "remark": "Bla bla Bla"
      },
      {
        "name": "engine",
        "label": "Rendering engine",
        "sortable": true,
        "searchable": true,
        "popOver": {
          "body": "Popover 内容：${platform}",
          "trigger": "hover"
        },
        "popOverEnableOn": "this.id === 1",
        "type": "text",
        "toggled": true
      },
      {
        "name": "browser",
        "label": "Browser",
        "sortable": true,
        "type": "text",
        "toggled": false
      },
      {
        "name": "platform",
        "label": "Platform(s)",
        "popOver": {
          "body": "Popover 内容：${platform}"
        },
        "sortable": true,
        "type": "text",
        "toggled": true
      },
      {
        "name": "version",
        "label": "Engine version",
        "quickEdit": true,
        "type": "text",
        "toggled": true,
        "filterable": {
          "options": [
            {
              "label": "4",
              "value": "4"
            },
            {
              "label": "5",
              "value": "5"
            },
            {
              "label": "6",
              "value": "6"
            }
          ]
        },
        "classNameExpr": "<%= data.version < 5 ? 'bg-danger' : '' %>"
      },
      {
        "type": "text",
        "name": "grade",
        "label": "CSS grade",
        "quickEdit": {
          "saveImmediately": true,
          "mode": "inline",
          "type": "select",
          "options": [
            "A",
            "B",
            "C",
            "D",
            "X"
          ]
        }
      },
      {
        "type": "operation",
        "label": "操作",
        "width": 100,
        "buttons": [
          {
            "type": "button",
            "icon": "fa fa-eye",
            "actionType": "dialog",
            "tooltip": "查看",
            "dialog": {
              "title": "查看",
              "body": {
                "type": "form",
                "body": [
                  {
                    "type": "static",
                    "name": "engine",
                    "label": "Engine"
                  },
                  {
                    "type": "divider"
                  },
                  {
                    "type": "static",
                    "name": "browser",
                    "label": "Browser"
                  },
                  {
                    "type": "divider"
                  },
                  {
                    "type": "static",
                    "name": "platform",
                    "label": "Platform(s)"
                  },
                  {
                    "type": "divider"
                  },
                  {
                    "type": "static",
                    "name": "version",
                    "label": "Engine version"
                  },
                  {
                    "type": "divider"
                  },
                  {
                    "type": "static",
                    "name": "grade",
                    "label": "CSS grade"
                  },
                  {
                    "type": "divider"
                  },
                  {
                    "type": "html",
                    "html": "<p>添加其他 <span>Html 片段</span> 需要支持变量替换（todo）.</p>"
                  }
                ]
              }
            }
          },
          {
            "type": "button",
            "icon": "fa fa-pencil",
            "tooltip": "编辑",
            "actionType": "drawer",
            "drawer": {
              "position": "left",
              "size": "lg",
              "title": "编辑",
              "body": {
                "type": "form",
                "name": "sample-edit-form",
                "api": "/amis/api/sample/$id",
                "body": [
                  {
                    "type": "input-text",
                    "name": "engine",
                    "label": "Engine",
                    "required": true
                  },
                  {
                    "type": "divider"
                  },
                  {
                    "type": "input-text",
                    "name": "browser",
                    "label": "Browser",
                    "required": true
                  },
                  {
                    "type": "divider"
                  },
                  {
                    "type": "input-text",
                    "name": "platform",
                    "label": "Platform(s)",
                    "required": true
                  },
                  {
                    "type": "divider"
                  },
                  {
                    "type": "input-text",
                    "name": "version",
                    "label": "Engine version"
                  },
                  {
                    "type": "divider"
                  },
                  {
                    "type": "select",
                    "name": "grade",
                    "label": "CSS grade",
                    "options": [
                      "A",
                      "B",
                      "C",
                      "D",
                      "X"
                    ]
                  }
                ]
              }
            }
          },
          {
            "type": "button",
            "icon": "fa fa-times text-danger",
            "actionType": "ajax",
            "tooltip": "删除",
            "confirmText": "您确认要删除?",
            "api": "delete:/amis/api/sample/$id"
          }
        ],
        "toggled": true
      }
    ]
  }
});
    })();
</script>
</body>
</html>